//
//  SaleReportsCell.m
//  UI Demo
//
//  Created by Rainy Zou on 15/11/30.
//  Copyright © 2015年 Rainy Zou. All rights reserved.
//

#import "SaleReportsCell.h"

@interface SaleReportsCell()
@property (weak,nonatomic) UILabel *label;
@property (weak,nonatomic) UIButton *btn;
@end

@implementation SaleReportsCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if(self == [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        UILabel *labelView = [[UILabel alloc]init];
        self.label  = labelView;
        
        [self.contentView addSubview:labelView];
        
        UIButton *buttonView = [[UIButton alloc]init];
        
        self.btn = buttonView;
        
        [self.contentView addSubview:buttonView];
    }
    return self;
}

-(void)setCellWithName:(NSString *)name image:(NSString *)imageName
{
    CGSize size = [name sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:CGSizeMake(self.frame.size.width, MAXFLOAT)];
    self.label.text = name;
    self.label.frame = CGRectMake(0, 0, MAX(self.frame.size.width, size.width), size.height);
    self.label.textAlignment = NSTextAlignmentCenter;
    
    
    [self.btn setBackgroundImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    self.btn.frame = CGRectMake(10, CGRectGetMaxY(self.label.frame), self.frame.size.width - 2*10, 175);
    self.btn.enabled = NO;
    
    NSLog(@"button width: %lf",self.frame.size.width);
}

- (void)awakeFromNib {
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
